package com.gzc.just.play.last.war.sceneserver.goods;

/**
 * 物品配置 - 表示单个物品的配置
 *
 * 对应C++的 SGoodsCfg
 *
 * @author AI编程助手
 * @version 1.0
 * @since 2025-11-22
 */
public class GoodsConfig {
    
    private final int goodsId;           // 物品ID
    private final String name;           // 物品名称
    private final String description;    // 物品描述
    private final GoodsType goodsType;   // 物品类型
    private final int level;             // 物品等级
    private final int price;             // 购买价格（金币）
    private final int sellPrice;         // 售卖价格
    private final int maxStack;          // 最大堆叠数
    private final int weight;            // 重量
    
    // 效果属性
    private final int attackBonus;       // 攻击加成
    private final int defenseBonus;      // 防御加成
    private final int healthBonus;       // 生命加成
    private final int manaBonus;         // 魔力加成
    private final int speedBonus;        // 速度加成
    
    // 消耗品属性
    private final int healthRestore;     // 恢复生命值
    private final int manaRestore;       // 恢复魔力值
    
    // 其他
    private final boolean tradeable;     // 是否可交易
    private final boolean sellable;      // 是否可售卖
    private final String rarity;         // 稀有度 (common, uncommon, rare, epic, legendary)
    
    /**
     * 创建物品配置
     */
    public GoodsConfig(int goodsId, String name, String description, GoodsType goodsType,
                      int level, int price, int sellPrice, int maxStack, int weight,
                      int attackBonus, int defenseBonus, int healthBonus, int manaBonus,
                      int speedBonus, int healthRestore, int manaRestore,
                      boolean tradeable, boolean sellable, String rarity) {
        this.goodsId = goodsId;
        this.name = name;
        this.description = description;
        this.goodsType = goodsType;
        this.level = level;
        this.price = price;
        this.sellPrice = sellPrice;
        this.maxStack = maxStack;
        this.weight = weight;
        this.attackBonus = attackBonus;
        this.defenseBonus = defenseBonus;
        this.healthBonus = healthBonus;
        this.manaBonus = manaBonus;
        this.speedBonus = speedBonus;
        this.healthRestore = healthRestore;
        this.manaRestore = manaRestore;
        this.tradeable = tradeable;
        this.sellable = sellable;
        this.rarity = rarity;
    }
    
    // Getters
    public int getGoodsId() {
        return goodsId;
    }
    
    public String getName() {
        return name;
    }
    
    public String getDescription() {
        return description;
    }
    
    public GoodsType getGoodsType() {
        return goodsType;
    }
    
    public int getLevel() {
        return level;
    }
    
    public int getPrice() {
        return price;
    }
    
    public int getSellPrice() {
        return sellPrice;
    }
    
    public int getMaxStack() {
        return maxStack;
    }
    
    public int getWeight() {
        return weight;
    }
    
    public int getAttackBonus() {
        return attackBonus;
    }
    
    public int getDefenseBonus() {
        return defenseBonus;
    }
    
    public int getHealthBonus() {
        return healthBonus;
    }
    
    public int getManaBonus() {
        return manaBonus;
    }
    
    public int getSpeedBonus() {
        return speedBonus;
    }
    
    public int getHealthRestore() {
        return healthRestore;
    }
    
    public int getManaRestore() {
        return manaRestore;
    }
    
    public boolean isTradeable() {
        return tradeable;
    }
    
    public boolean isSellable() {
        return sellable;
    }
    
    public String getRarity() {
        return rarity;
    }
    
    /**
     * 检查是否是消耗品
     */
    public boolean isConsumable() {
        return goodsType.isConsumable();
    }
    
    /**
     * 检查是否是装备
     */
    public boolean isEquipment() {
        return goodsType.isEquipment();
    }
    
    /**
     * 获取稀有度等级（数值）
     */
    public int getRarityLevel() {
        switch (rarity.toLowerCase()) {
            case "common":
                return 1;
            case "uncommon":
                return 2;
            case "rare":
                return 3;
            case "epic":
                return 4;
            case "legendary":
                return 5;
            default:
                return 0;
        }
    }
    
    /**
     * 获取总属性加成
     */
    public int getTotalBonus() {
        return attackBonus + defenseBonus + healthBonus + manaBonus + speedBonus;
    }
    
    @Override
    public String toString() {
        return String.format("GoodsConfig{id=%d, name='%s', type=%s, level=%d, price=%d}",
            goodsId, name, goodsType.getDisplayName(), level, price);
    }
}
